#ifndef EXTEND_H
#define EXTEND_H

#include<time.h>
#include<yara/zlib.h>
#ifdef _WIN32
#include <windows.h>
void socket_def(SOCKET *sock, char *host, int port);
#else
void socket_def(int *sock,char *host_t,int port_t);
#endif

void *allocate_one_dimension( int a);

char**allocate_two_dimension(int a, int b);

char  *allocate_one_dimension_s(int a);

void free_two_dimension(char** ptr,int a);

char *get_open_file_stream(char *filepath);

int get_open_file_length(char *filepath);

void  get_webroot_path(char **s);

void get_webroot_path_reg(char *target, char **s, int *count);

void  sub_string(char* src, int pos, int length, char *dst);

char *str_replace(char *src, char *search, char *replace);

char*replace(char*src, char*sub, char*dst);

void  split_yr_dword(char *src, int count, char** dest, int* pCount, int length);

char *bin_to_string();

char  *dword_to_byte(char *a, int b);

char * delete_00(char *a, int b);

void  split_yr(char *src, char** dest, int* pCount, int length);

int  longest_word_length(char *src, int length,int threshold);

void  split_yr_common_in_main(char *src, char *delimit, char** dest, int* pCount, int length);

void  split_yr_common_in_main_(char *src, char delimit, char** dest, int* pCount, int length);

void string_ratio(char *s, char *target, float *ratio, unsigned long long data_len);

char * get_file_create_time(char *data);

char *get_time_now();

typedef struct file
{
    char *filename;
    int  filesize;
    char *filebuf;
    char * identifier;
    int used;
    char *md5;
    
    struct   file * next;
}file;

typedef struct all_web_shell_file
{
    char *filepath;
    struct all_web_shell_file *next;
}all_web_shell_file;

typedef struct return_url
{
    char *url;
    file *file;
    time_t add_time;
    struct return_url *next;


}return_url;

return_url *get_r_head();

return_url * delete_return_url_list(return_url * c);

return_url * delete_return_url_list_p(return_url * r_head, int i);

typedef   struct result_list
{
    char * result;
    struct result_list *next;
}result_list;

file *create(file * head, int a);

file * filter(file * head);

void insert(file * c, int i, int e);

int  send_to_server(file *head);

int  send_to_server_report(return_url *head, char *write_to_file_buf);

unsigned char * get_offset_from_code_start(unsigned long long a, unsigned char  * ip);  //xi

unsigned char * get_offset_from_code_start_ip( unsigned char  * ip,int *count);

void set_mode(int a);

int  get_mode();

void set_tlsh_mode(int a);

int  get_tlsh_mode();

int _count_string(char *data, char *key);

int count_bin(char *data, char key, int count);

char *malloc_replace(char *data, char *rep, char *to, int free_data);

void normal_replace(char *data, char *rep, char *to);

void set_over(int a);

int  get_over();

void set_file(file * a);

file * get_file();

void set_webshell_buf(char *buf);

char *  get_webshell_buf();

void set_web_shell_file(all_web_shell_file * a);

all_web_shell_file * get_web_shell_file();

file * delete_web_shell_file_from_all_file_list(file * file_head, int i);

file * delete_all_file_list(file * a_head, int i);

file * group(file * head, time_t start_time, int timeout);

void set_all_file_over(int a);

int  get_all_file_over();

void set_brute_mode(int a);

int  get_brute_mode();

void set_write_buf(char* a);

char *  get_write_buf();

void set_show_strings(int a);

int get_show_strings();

void set_algorithm(int a);

int get_algorithm();

uLong compressBound(uLong sourceLen);

int  compress(Bytef *dest,
    uLongf *destLen,
    const Bytef *source,
    uLong sourceLen);

void set_algorithm_buf(char **a);

char **get_algorithm_buf();

void set_array_webshell(float *a);

float*get_array_webshell();

void set_array_not_webshell(float *a);

float*get_array_not_webshell();

int check_file_type(unsigned char *a,char *suffix,int size);

int check_file_type_algorithm(char *a);

void  split_yr_common(char *src, char delimit, char** dest, int* pCount, int length, int length_of_dest);

char *ends_with(char *a);

unsigned char * get_offset_whitelist(unsigned char  * ip);

unsigned char* get_code_start();

void set_code_start(unsigned char *a);

#endif





